import java.util.Scanner;
public class Sum{
   public static void main(String[] args){
        Scanner input =new Scanner (System.in);
        System.out.print("请输入数字");
        int num=input.nextInt();
        System.out.println("各位数之和为："+sum(num));
input.close();};
public static int sum(int num){
int sum=0;
while(num!=0){
int val=num%10;
sum+=val;
num=num/10;
}
return sum;
}
}